<?php
	header("Content-Type: text/html;charset=utf-8");
	include("function/_nosql.php"); //
	include("function/function.php");
	include("function/function.email.php");

	$action = chkstr(trim($_REQUEST['action']));
	$user_email = chkstr(trim($_REQUEST['user_email']));
	if(!isEmail($user_email)){
		echo "邮箱格式错误！"; // 用户名格式不正确
		exit();
	}
	$EmailCode = randomkeys(6);
	$UrlsFix = explode("@",$user_email);
	$ToUrls = "http://mail.".$UrlsFix[1];
	$is_reguser = getNewsNums("kboy_user","user_email='$user_email'");
	if($action == "getpwd"){
		if($is_reguser <1){
			echo "该用户不存在！";
			exit();
		}
	}else{
		if($is_reguser >0){
			echo "该邮箱已被注册！";
			exit();
		}
	}

	$_SESSION['EmailName'] = "";
	$_SESSION['EmailCode'] = "";
?>
<div class="award-box">
    <div class="award-hd">
        <div class="award-tips"><img src="images/confirm.png" alt=""/></div>
        <div class="award-notice">验证码我们已经通过邮件形式发送到您邮箱<?=$user_email?>，请注意查收！</div>
        <span class="rect"></span>
    </div>
    <div class="award-bd">
        <a href="<?=$ToUrls?>" class="watch" target="_blank">前往邮箱查看</a>
    </div>
</div>
<?php
	$EmailState = POST_EMAIL($user_email,"邮箱验证码","您的验证码是".$EmailCode);
	if($EmailState != 1){
		echo erro("验证码发送失败");
	}else{
		$_SESSION['EmailName'] = $user_email;
		$_SESSION['EmailCode'] = $EmailCode;
	}
?>